<?php
function openUrl($url){
	// create curl resource
	$ch = curl_init();

	// set url
	curl_setopt($ch, CURLOPT_URL, $url);

	//return the transfer as a string
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

	// $output contains the output string
	$output = curl_exec($ch);

	// close curl resource to free up system resources
	curl_close($ch);   
	return $output;
}
function getXmlFromUrl($url){
	$restRes=openUrl($url);
	return simplexml_load_string($restRes);
}
function getXmlVideo($videoId){
	$restVideo = "http://gdata.youtube.com/feeds/api/videos/";
	//$videoId="D3Pfo3EIXLw"; http://gdata.youtube.com/feeds/api/videos/eeaC8Iy_Nf0
	//$entry = simplexml_load_file( $restVideo . $videoId);
	$restRes=openUrl($restVideo . $videoId);
	//echo $restRes;
	if($restRes=="Video not found" || strpos($restRes, "<")===false || strpos($restRes,"<yt:noembed/>")!==false){
		return false;
	}
	$xml = simplexml_load_string($restRes);
	//var_dump($xml);//mostra a estrutura do objeto
	return $xml;
}

?>